handshakes n = (f * (n-1) * n) `div` (2 * f)
    where f = product [1..x]

main = do
    c <- getContents
    let ns = map handshakes $ map read $ tail $ lines c
    putStr $ unlines $ map show ns